<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
    <style>
        html,
        body {
            width: 100%;
            min-height: 100%;
            background: #f0f0f0;
        }

        .h10 {
            height: 10px;
            background: #f0f0f0;
        }

        .h1 {
            height: 1px;
            margin-left: 15px;
            background: #f0f0f0;
        }

        .fr {
            float: right;
        }

        .hint {
            color: #666;
            font-size: 12px;
            margin-right: 5px;
        }

        .aui-title {
            color: #fff
        }

        [v-cloak] {
            display: none;
        }

        .presshover {
            background-color: #FAFAFA;
        }
    </style>
</head>

<body>
    <div id="app">

        <header id="header_top" class="aui-bar aui-bar-nav" style="">

            <a class="aui-pull-left" onclick="openCloseBack()">
                <span class="aui-iconfont aui-icon-left"></span>
            </a>
            <div class="aui-title">半空中男人</div>

        </header>

    </div>

</body>

<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/zepto.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
    function openCloseBack() {
        api.closeWin();


        // 查看消息后 页面的获取消息总数方法
        api.execScript({
            name: 'root',
            script: 'get_alll_msg();'
        });

        api.execScript({
            name: 'root',
            frameName: 'user_info',
            script: 'reload_frm();'
        });





        var rong = api.require('rongCloud2');
        rong.init(function(ret, err) {
            if (ret.status == 'error')
                api.toast({
                    msg: err.code
                });
        });

        rong.connect({
            token: $api.getStorage('rong-token')
        }, function(ret, err) {
            // console.log('首页打开后判断用户是否登录---获取当前用户的所有未读消息--- ' + JSON.stringify(ret));
            if (ret.status == 'success') {
                //获取当前用户所有未读消息的总数
                rong.getTotalUnreadCount(function(ret, err) {
                    console.log('消息列表页面获取到的未读消息总数---' + ret.result)
                    api.sendEvent({
                        name: 'send_info_num',
                        extra: {
                            msg_num: ret.result
                        }
                    });
                })
            }
        });

    }

    function apiready() {
      if(!$api.getStorage('token')){
        api.confirm( {
            title: '是否登录',
            msg: '确认是否登录？',
            buttons: [ '确定', '取消' ]
          }, function ( ret, err ) {
            var index = ret.buttonIndex;
            if ( index == 1 ) {
              api.openWin({
                name: 'login',
                url: '../five_frame/login_header.html',
                delay: 200,
                bounces: false
              });
              return;
            } else {
              api.closeWin({
                  name: name
              });
              return
            }
          })
          return
        }
      api.addEventListener({
          name: 'keyback'
      }, function(ret, err) {
        api.closeWin();
        // 查看消息后 页面的获取消息总数方法
        api.execScript({
            name: 'root',
            script: 'get_alll_msg();'
        });
      });

        var header_top = $api.byId('header_top');
        var header_topPos = $api.offset(header_top);
        $api.fixStatusBar(header_top);


        var headerH = $('#app').height();

        $('.aui-title').html(api.pageParam.name);

        api.openFrame({
            name: 'user_info_details_frm',
            url: './user_info_details_frm.html',
            rect: {
                x: 0,
                y: headerH,
                w: 'auto',
                h: 'auto'
            },
            pageParam: {
                id: api.pageParam.id,
                name: api.pageParam.name,
                chat_type: api.pageParam.chat_type
            },
            bounces: false,
            bgColor: '#fff',
            vScrollBarEnabled: true,
            hScrollBarEnabled: true
        });
    }


    function change_name(name) {
        console.log('11111' + name);
        $('.aui-title').html(name);
    }
</script>

</html>
